package model.item;

import java.util.List;

import model.map.GameTile;
import model.mapping.ItemMapping;

public abstract class Item
{
	private String type;
	private int radius;
	private ItemMapping itemMapping;
	
	public Item(String type, int radius, ItemMapping im)
	{
		this.type = type;
		this.radius = radius;
		itemMapping = im;
	}
	
	public String getType()
	{
		return type;
	}
	
	public int getRadius()
	{
		return radius;
	}
	
	public ItemMapping getItemMapping()
	{
		return itemMapping;
	}
	
	public List<GameTile> getAffectedTiles()
	{
		return itemMapping.getTilesAround(this);
	}
	
	public void trigger()
	{
		List<GameTile> tiles = getAffectedTiles();
		for (GameTile t : tiles)
		{
			
			if (t == null)
				System.out.println("Null tile");
			else 
				System.out.println(t);
				
			
			itemMapping.affectPlayablesOn(t, this);
		}
		
		itemMapping.removeItem(this);
	}
	public abstract void affect(ItemUser p);
}
